package com.carol.lmsbe.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.carol.lmsbe.entity.Equipment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 设备Mapper接口
 */
@Mapper
public interface EquipmentMapper extends BaseMapper<Equipment> {

    /**
     * 根据实验室ID查询设备列表
     */
    @Select("SELECT e.*, l.name as laboratory_name " +
            "FROM equipment e " +
            "LEFT JOIN laboratory l ON e.laboratory_id = l.id " +
            "WHERE e.laboratory_id = #{laboratoryId}")
    List<Equipment> selectByLaboratoryId(@Param("laboratoryId") Long laboratoryId);

    /**
     * 根据状态查询设备列表
     */
    @Select("SELECT e.*, l.name as laboratory_name " +
            "FROM equipment e " +
            "LEFT JOIN laboratory l ON e.laboratory_id = l.id " +
            "WHERE e.status = #{status}")
    List<Equipment> selectByStatus(@Param("status") String status);

    /**
     * 根据类别查询设备列表
     */
    @Select("SELECT e.*, l.name as laboratory_name " +
            "FROM equipment e " +
            "LEFT JOIN laboratory l ON e.laboratory_id = l.id " +
            "WHERE e.category = #{category}")
    List<Equipment> selectByCategory(@Param("category") String category);
}
